package com.smart_environmental_protection.dao;

import com.smart_environmental_protection.pojo.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface OrderDao {
    @Select("select * from s_order where state=#{state} and userId=#{userId}")
    List<Order> OrderList(Integer state,Integer userId);

    @Select("select * from s_order where id=#{id}")
    Order SelOrder(Integer id);

    @Update("UPDATE s_order SET state = #{state} WHERE id = #{id}")
    int UpdOrder(Order order);

//    @Select("select id from s_order where #{createTime} and #{coverUrl} and #{goodTypeName} and #{goodNumber} and #{goodUnitPrice} and #{pickupTime} and #{state} and #{userId} and #{goodUnit} and #{pickupAddress} and #{companyName}, #{orderPrice}, #{remark}, #{nickName}, #{phoneNum}")
//    Order SleId(Order order);
    @Insert("INSERT INTO `smartep`.`s_order`(`createTime`, `coverUrl`, `goodTypeName`, `goodNumber`, `goodUnitPrice`, `pickupTime`, `state`, `userId`, `goodUnit`, `pickupAddress`, `companyName`, `orderPrice`, `remark`, `nickName`, `phoneNum`) VALUES (#{createTime},#{coverUrl}, #{goodTypeName}, #{goodNumber}, #{goodUnitPrice}, #{pickupTime}, #{state}, #{userId}, #{goodUnit}, #{pickupAddress}, #{companyName}, #{orderPrice}, #{remark}, #{nickName}, #{phoneNum})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int InsertOrder(Order order);

    @Update("UPDATE s_order SET coverUrl = #{coverUrl} WHERE id = #{id}")
    int setIcon(Order order);



}
